using System;
using System.Collections.Generic;
using System.IO;

namespace lucere.index.diagnostic
{
    /// <summary>
    ///  Basic tool and API to check the health of an index and
    ///  write a new segments file that removes reference to
    ///  problematic segments.
    ///  <para>As this tool checks every byte in the index, on a large
    ///  index it can take quite a long time to run.
    ///  </para>
    ///  <p><b>WARNING</b>: this tool and API is new and
    ///  experimental and is subject to suddenly change in the
    ///  next release.  Please make a complete backup of your
    ///  index before using this to fix your index!
    /// </summary>
    public interface ICheckIndex 
    {
        /// <summary>
        /// Set infoStream where messages should go.  If null, no messages are printed 
        /// </summary>
        /// <param name="?"></param>
        void SetInfoStream(TextWriter output);
      
        /// <summary>
        /// Returns a IStatus instance detailing the state of the index.
        /// <para>
        /// As this method checks every byte in the index, on a large 
        /// index it can take quite a long time to run.
        /// </para>
        /// </summary>
        /// <returns></returns>
        IStatus CheckIndex();

        /// <summary>
        /// Returns a IStatus instance detailing the state of the index.
        /// <para>As this method checks every byte in the specified segments, on a large index it can take quite a long time to run.</para>
        /// <param name="onlySegments">list of specific segment names to check</param>
        /// </summary>
        IStatus CheckIndex(IList<String> onlySegments);
    
        /// <summary>
        /// Repairs the index using previously returned result from CheckIndex.  
        /// Note that this does not remove any of the unreferenced files after 
        /// it's done; you must separately open an IIndexWriter, which deletes 
        /// unreferenced files when it's created.
        /// <para>WARNING: this writes a new segments file into the index, effectively removing all documents in broken segments from the index. BE CAREFUL.</para>
        /// <para>WARNING: Make sure you only call this when the index is not opened  by any writer.</para>
        /// </summary>
        void FixIndex(IStatus result);
    }
}